﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIOptimization.Algorithms.Repositories
{
    public class Bacterium : IComparable<Bacterium>
    {
        public int colonyIndex { get; set; }
        public double[] position { get; set; }
        public double cost { get; set; }
        public double prevCost { get; set; }
        public double health { get; set; }
        static Random rd = new Random(0);

        public Bacterium(int colonyIndex,int dimension, double minValue, double maxValue)
        {
            this.position = new double[dimension];
            for (int p = 0; p < dimension; ++p)
            {
                double x = (maxValue - minValue) * rd.NextDouble() + minValue;
                this.position[p] = x;
            }
            this.health = 0.0;
        }

        public Bacterium()
        {

        }
        public int CompareTo(Bacterium other)
        {
            if (this.health < other.health)
                return -1;
            else if (this.health > other.health)
                return 1;
            else
                return 0;
        }
    }

    public class BestBacteriumResult : EventArgs
    {
        public int Bacteria { get; set; }
        public int Time { get; set; }
        public double Cost { get; set; }
        public double[] Position { get; set; }
        public BestBacteriumResult(int Bacteria, int Time, double Cost,double[] Position)
        {
            this.Bacteria = Bacteria;
            this.Time = Time;
            this.Cost = Cost;
            this.Position = Position;
        }
    }
}
